package com.java.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author jingjintao
 * @date 2021/8/14 - 17:57
 **/
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        //http://news.baidu.com/guoji
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_atguigu", r ->
            r.path("/guonei").uri("http://news.baidu.com/guoji"))
                .route("path_route_atguigu2",r ->
                        r.path("/game").uri("http://news.baidu.com/game"))
                .build();
        return routes.build();
    }
}
